home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5710 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: po.CWRU.Edu!mab22
  2. From: mab22@po.CWRU.Edu (Michael A. Balfour)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: String Arrays and string parsing
  5. Date: 20 Feb 1996 22:47:59 GMT
  6. Organization: Case Western Reserve University, Cleveland, OH (USA)
  7. Message-ID: <4gdj2v$bb1@madeline.INS.CWRU.Edu>
  8. References: <31287278.789445@news.inforamp.net>
  9. Reply-To: mab22@po.CWRU.Edu (Michael A. Balfour)
  10. NNTP-Posting-Host: kanga.ins.cwru.edu
  11.  
  12.  
  13. In a previous article, dsheuman@inforamp.net (Danny Heuman) says:
  14.  
  15. >I have day, month, and year as DDMMMYYYY and would like to parse it
  16. >out in to DD, MMM, YYYY.  I can parse the DD out by using
  17. >strncpy(into1, from1, 2).  I can parse the YYYY out by doing
  18. >strcpy(into3, from1 + 5).  How can I parse out the MMM?  Can I use
  19. >either of these functions that work above, strncpy or strcpy?  If so,
  20. >once parsed, do I have to attach an '\0' to the end of it to keep it
  21. >as a character string?
  22. >
  23. How about strncpy(into2, from1 + 2, 3)?  You will have to attach an '\0'
  24. to into1 and into2.  Not too difficult, though:
  25.     into1[2]=into2[3]='\0';
  26.  
  27. Mike Balfour
  28. -- 
  29. ----------------------------------+--------------------------------
  30. Mike Balfour, Partner             | BS/MS Graduate - ECMP
  31. Overload Engineering              | Case Western Reserve University
  32. "New Ideas for a Brighter Future" | Cleveland, OH
  33.